# $Id: PKGBUILD 173245 2012-12-15 23:57:30Z stephane $
# Maintainer: Stéphane Gaudreault <stephane@archlinux.org>
# Contributor: Alexander Fehr <pizzapunk gmail com>

pkgbase=python-logilab-astng
pkgname=('python2-logilab-astng' 'python-logilab-astng')
pkgver=0.24.1
pkgrel=3
pkgdesc="Extend python's abstract syntax tree"
arch=('any')
url="http://www.logilab.org/project/logilab-astng"
license=('LGPL')
makedepends=('python-logilab-common' 'python2-logilab-common')
source=(http://download.logilab.org/pub/astng/logilab-astng-${pkgver}.tar.gz)
sha1sums=('067922aed15f3d3025c04e6532c65c420ed86497')

build() {
  cd "${srcdir}"
  cp -a logilab-astng-${pkgver}{,-py3}

  cd logilab-astng-${pkgver}
  python2 setup.py build

  cd ../logilab-astng-${pkgver}-py3
  find test/ -name \*.py -exec 2to3 -nw {} \;
  python3 setup.py build
}

package_python2-logilab-astng() {
  depends=('python2-logilab-common')
  cd "${srcdir}"/logilab-astng-${pkgver}

  python2 setup.py install --prefix=/usr --root="${pkgdir}" --skip-build --optimize=1

  # Resolve conflict with python-logilab-common
  rm "${pkgdir}"/usr/lib/python2.7/site-packages/logilab/__init__.py

  find "${pkgdir}" -type f -exec chmod ugo+r {} \;
}

package_python-logilab-astng() {
  depends=('python-logilab-common')
  cd "${srcdir}"/logilab-astng-${pkgver}-py3

  python3 setup.py install --prefix=/usr --root="${pkgdir}" --skip-build --optimize=1

  # Resolve conflict with python-logilab-common
  rm "${pkgdir}"/usr/lib/python3.3/site-packages/logilab/__init__.py

  find "${pkgdir}" -type f -exec chmod ugo+r {} \;
}
